// tango frenzy.cpp : Defines the entry point for the application.
//


#include "stdafx.h"
#include "tango frenzy.h"
//#include "00.h"



#define MAX_LOADSTRING 100
//bool reftree =false;
int ret,numar_noduri=0,op=0,pro=0;
int cautat=0,qwerty=0,tru=0;
bool fac_cautare=0;

// Global Variables:
extern nod* headref, * headtango;
nod * parc_t=NULL, * parc_aux=NULL, * head_aux=NULL;						//parc_t pointer care parcurge tango tree , parc_aux pointer care parcurge arburele auxiliar
extern lista * first;
lista * parc_lista=NULL;								//parc_lista pointer care parcurge lista pana la arborele auxiliar
HPEN hPenOld;
HDC hdc;
HWND hWnd1;
char s[3];

HWND btnext=NULL;
HWND hWndComboBox;
HINSTANCE hInst,hcombo;							// current instance
TCHAR szTitle[MAX_LOADSTRING];					// The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];			// the main window class name


// Forward declarations of functions included in this code module:
ATOM				MyRegisterClass(HINSTANCE hInstance);
BOOL				InitInstance(HINSTANCE, int);
LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK	About(HWND, UINT, WPARAM, LPARAM);

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

 	// TODO: Place code here.
	MSG msg;
	HACCEL hAccelTable;

	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_TANGOFRENZY, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);

	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow))
	{
		return FALSE;
	}

	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_TANGOFRENZY));

	// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	return (int) msg.wParam;
}



BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
	

    switch(Message)
    {
        case WM_INITDIALOG:
			SendMessage(hWndComboBox,
                        CB_ADDSTRING,
                        0,
                        reinterpret_cast<LPARAM>((LPCTSTR)"15"));
			
			SendMessage(hWndComboBox,
                        CB_ADDSTRING,
                        0,
                        reinterpret_cast<LPARAM>((LPCTSTR)"31"));
			
			SendMessage(hWndComboBox, CB_SETCURSEL, 1, 0);
        return TRUE;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
				case IDC_RADIO1:
					op=15;
					break;
				case IDC_RADIO2:
					op=31;
					break;
                case IDD_OK:
					numar_noduri=op;
                    EndDialog(hwnd, IDD_OK);
                break;
                case IDD_CANCEL:
					op=numar_noduri;
                    EndDialog(hwnd, IDD_CANCEL);
                break;
            }
        break;
        default:
            return FALSE;
    }
    return TRUE;
}

BOOL CALLBACK AboutDlgProc1(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
	

    switch(Message)
    {
        case WM_INITDIALOG:
			SendMessage(hWndComboBox,
                        CB_ADDSTRING,
                        0,
                        reinterpret_cast<LPARAM>((LPCTSTR)"15"));
			
			SendMessage(hWndComboBox,
                        CB_ADDSTRING,
                        0,
                        reinterpret_cast<LPARAM>((LPCTSTR)"31"));
			
			SendMessage(hWndComboBox, CB_SETCURSEL, 1, 0);
        return TRUE;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {	
				case IDC_RADIO3:
					//cautare pentru nodul 1 din arbore 31
					qwerty=1;
					tru=1;
					break;
				case IDC_RADIO4:
					//cautare pentru nodul 2 din arbore 31
					qwerty=2;
					tru=1;
					break;
				case IDC_RADIO5:
					qwerty=3;
					tru=1;
					break;
				case IDC_RADIO6:
					qwerty=4;
					tru=1;
					break;
				case IDC_RADIO7:
					qwerty=5;
					tru=1;
					break;
				case IDC_RADIO8:
					qwerty=6;
					tru=1;
					break;
				case IDC_RADIO9:
					qwerty=7;
					tru=1;
					break;
				case IDC_RADIO10:
					qwerty=8;
					tru=1;
					break;
				case IDC_RADIO11:
					qwerty=9;
					tru=1;
					break;
				case IDC_RADIO12:
					qwerty=10;
					tru=1;
					break;
				case IDC_RADIO13:
					qwerty=11;
					tru=1;
					break;
				case IDC_RADIO14:
					qwerty=12;
					tru=1;
					break;
				case IDC_RADIO15:
					qwerty=13;
					tru=1;
					break;
				case IDC_RADIO16:
					qwerty=14;
					tru=1;
					break;
				case IDC_RADIO17:
					qwerty=15;
					tru=1;
					break;
				case IDC_RADIO18:
					qwerty=16;
					tru=1;
					break;
				case IDC_RADIO19:
					qwerty=17;
					tru=1;
					break;
				case IDC_RADIO20:
					qwerty=18;
					tru=1;
					break;
				case IDC_RADIO21:
					qwerty=19;
					tru=1;
					break;
				case IDC_RADIO22:
					qwerty=20;
					tru=1;
					break;
				case IDC_RADIO23:
					qwerty=21;
					tru=1;
					break;
				case IDC_RADIO24:
					qwerty=22;
					tru=1;
					break;
				case IDC_RADIO25:
					qwerty=23;
					tru=1;
					break;
				case IDC_RADIO26:
					qwerty=24;
					tru=1;
					break;
				case IDC_RADIO27:
					qwerty=25;
					tru=1;
					break;
				case IDC_RADIO28:
					qwerty=26;
					tru=1;
					break;
				case IDC_RADIO29:
					qwerty=27;
					tru=1;
					break;
				case IDC_RADIO30:
					qwerty=28;
					tru=1;
					break;
				case IDC_RADIO31:
					qwerty=29;
					tru=1;
					break;
				case IDC_RADIO32:
					qwerty=30;
					tru=1;
					break;
				case IDC_RADIO33:
					qwerty=31;
					tru=1;
					break;
                case IDD_OK:
					if (tru)
						fac_cautare=1;
					else
						fac_cautare=0;
					cautat=qwerty;
					tru=0;
                    EndDialog(hwnd, IDD_OK);
                break;
                case IDD_CANCEL:
					tru=0;
					qwerty=cautat;
					fac_cautare=0;
					EndDialog(hwnd, IDD_CANCEL);
                break;
            }
        break;
        default:
            return FALSE;
    }
    return TRUE;
}

BOOL CALLBACK AboutDlgProc2(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
	

    switch(Message)
    {
        case WM_INITDIALOG:
			SendMessage(hWndComboBox,
                        CB_ADDSTRING,
                        0,
                        reinterpret_cast<LPARAM>((LPCTSTR)"15"));
			
			SendMessage(hWndComboBox,
                        CB_ADDSTRING,
                        0,
                        reinterpret_cast<LPARAM>((LPCTSTR)"31"));
			
			SendMessage(hWndComboBox, CB_SETCURSEL, 1, 0);
        return TRUE;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
			case IDC_RADIO3:
					//cautare pentru nodul 1 din arbore 15
					qwerty=1;
					tru=1;
					break;
				case IDC_RADIO4:
					//cautare pentru nodul 2 din arbore 15
					qwerty=2;
					tru=1;
					break;
				case IDC_RADIO5:
					qwerty=3;
					tru=1;
					break;
				case IDC_RADIO6:
					qwerty=4;
					tru=1;
					break;
				case IDC_RADIO7:
					qwerty=5;
					tru=1;
					break;
				case IDC_RADIO8:
					qwerty=6;
					tru=1;
					break;
				case IDC_RADIO9:
					qwerty=7;
					tru=1;
					break;
				case IDC_RADIO10:
					qwerty=8;
					tru=1;
					break;
				case IDC_RADIO11:
					qwerty=9;
					tru=1;
					break;
				case IDC_RADIO12:
					qwerty=10;
					tru=1;
					break;
				case IDC_RADIO13:
					qwerty=11;
					tru=1;
					break;
				case IDC_RADIO14:
					qwerty=12;
					tru=1;
					break;
				case IDC_RADIO15:
					qwerty=13;
					tru=1;
					break;
				case IDC_RADIO16:
					qwerty=14;
					tru=1;
					break;
				case IDC_RADIO17:
					qwerty=15;
					tru=1;
					break;
                case IDD_OK:
					if (tru)
						fac_cautare=1;
					else
						fac_cautare=0;
					cautat=qwerty;
					tru=0;
                    EndDialog(hwnd, IDD_OK);
                break;
                case IDD_CANCEL:
					tru=0;
					qwerty=cautat;
					fac_cautare=0;
					EndDialog(hwnd, IDD_CANCEL);
                break;
            }
        break;
        default:
            return FALSE;
    }
    return TRUE;
}

///functie buton de next 
BOOL CALLBACK AboutDlgProc4 (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{

    switch(Message)
    {
        case WM_INITDIALOG:
			return TRUE;
			break;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
			case IDD_OK:
				// facem prima afisare in 
				if (pro==0)
				if(!parc_aux)
				{
					parc_lista=first;
					while(parc_t->info!=parc_lista->radacina->info)
						parc_lista=parc_lista->next;
					parc_aux=parc_lista->radacina;
					head_aux=parc_aux;
				}
				//sterg arborele aux
								
				SendMessage(hWnd1,WM_PAINT,0,0);
				hdc = GetWindowDC(hWnd1);

				
				
				
				RECT *r;
				r=(RECT*)malloc(sizeof(RECT));
				r->left=0;
				r->top=370;
				r->right=1360;
				r->bottom=748;
				

				HBRUSH hbrush;
				hbrush=CreateSolidBrush(RGB(255,255,255));
				FillRect(hdc,r,hbrush);
				InvalidateRect(hWnd1,r,FALSE); 

				HPEN hLinePen15;
				COLORREF qLineColor15;
				qLineColor15 = RGB(0, 0, 0);
				hLinePen15 = CreatePen(PS_SOLID, 2, qLineColor15);
				hPenOld = (HPEN)SelectObject(hdc, hLinePen15);

				MoveToEx(hdc, 0, 374, NULL);
				LineTo(hdc, 1370, 374);
					
				SelectObject(hdc, hPenOld);
				DeleteObject(hLinePen15);
				
				
				
				if(head_aux)
				{
					HPEN hEllipsePen4;
					COLORREF qEllipseColor4;
					qEllipseColor4 = RGB(0, 210, 0);
					hEllipsePen4 = CreatePen(PS_SOLID, 2, qEllipseColor4);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen4);
					
					Arc(hdc, 316, 422, 356, 462, 0, 0, 0, 0);
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen4);

					HPEN hEllipsePen5;
					COLORREF qEllipseColor5;
					qEllipseColor5 = RGB(0, 0, 0);
					hEllipsePen5 = CreatePen(PS_SOLID, 2, qEllipseColor5);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen5);
					
					if(head_aux->left)
					{
						Arc(hdc, 144, 487, 184,527, 0, 0, 0, 0);
						if(head_aux->left->left)
						{
							Arc(hdc, 58, 552, 98,592, 0, 0, 0, 0);
							if(head_aux->left->left->left)
								Arc(hdc, 15, 617, 55,657, 0, 0, 0, 0);
							if(head_aux->left->left->right)
								Arc(hdc, 101, 617, 141,657, 0, 0, 0, 0);
						}
						if(head_aux->left->right)
						{
							Arc(hdc, 230, 552, 270,592, 0, 0, 0, 0);
							if(head_aux->left->right->left)
								Arc(hdc, 187, 617, 227,657, 0, 0, 0, 0);
							if(head_aux->left->right->right)
								Arc(hdc, 273, 617, 313,657, 0, 0, 0, 0);
						}

					}
					if(head_aux->right)
					{
						Arc(hdc, 488, 487, 528,527, 0, 0, 0, 0);
						if(head_aux->right->left)
						{
							Arc(hdc, 402, 552, 442,592, 0, 0, 0, 0);
							if(head_aux->right->left->left)
								Arc(hdc, 359, 617, 399, 657, 0, 0, 0, 0);
							if(head_aux->right->left->right)
								Arc(hdc, 445, 617, 485, 657, 0, 0, 0, 0);
						}
						if(head_aux->right->right)
						{
							Arc(hdc, 574, 552, 614,592, 0, 0, 0, 0);
							if(head_aux->right->right->left)
								Arc(hdc, 531, 617, 571,657, 0, 0, 0, 0);
							if(head_aux->right->right->right)
								Arc(hdc, 617, 617, 657,657, 0, 0, 0, 0);
						}
					}
					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen4);
					
					
					if(head_aux)
					{
						HPEN hLinePen8;
						COLORREF qLineColor8;
						qLineColor8 = RGB(0, 0, 0);
						hLinePen8 = CreatePen(PS_SOLID, 2, qLineColor8);
						hPenOld = (HPEN)SelectObject(hdc, hLinePen8);
						if(head_aux->left)
						{
							MoveToEx(hdc, 336, 462, NULL);
							LineTo(hdc, 164, 487);
							if(head_aux->left->left)
							{
								MoveToEx(hdc, 164, 527, NULL);
								LineTo(hdc, 78, 552 );
								if(head_aux->left->left->left)
								{
									MoveToEx(hdc, 78, 592, NULL);
									LineTo(hdc, 35,617 );
								}
								if(head_aux->left->left->right)
								{
									MoveToEx(hdc, 78, 592, NULL);
									LineTo(hdc, 121,617 );
								}
							}
							if(head_aux->left->right)
							{
								MoveToEx(hdc, 164, 527, NULL);
								LineTo(hdc, 250,552 );
								if(head_aux->left->right->left)
								{
									MoveToEx(hdc, 250, 592, NULL);
									LineTo(hdc, 207,617 );
								}
								if(head_aux->left->right->right)
								{
									MoveToEx(hdc, 250, 592, NULL);
									LineTo(hdc, 293,617 );
								}
							}
						}
						if(head_aux->right)
						{
							MoveToEx(hdc, 336, 462, NULL);
							LineTo(hdc, 508, 487);
							if(head_aux->right->left)
							{
								MoveToEx(hdc, 508, 527, NULL);
								LineTo(hdc, 422,552 );
								if(head_aux->right->left->left)
								{
									MoveToEx(hdc, 422, 592, NULL);
									LineTo(hdc, 379,617 );
								}
								if(head_aux->right->left->right)
								{
									MoveToEx(hdc, 422, 592, NULL);
									LineTo(hdc, 465,617 );
								}
							}
							if(head_aux->right->right)
							{
								MoveToEx(hdc, 508, 527, NULL);
								LineTo(hdc, 594,552 );
								if(head_aux->right->right->left)
								{
									MoveToEx(hdc, 594, 592, NULL);
									LineTo(hdc, 551,617 );
								}
								if(head_aux->right->right->right)
								{
									MoveToEx(hdc, 594, 592, NULL);
									LineTo(hdc, 637,617 );
								}
							}
						}
						SelectObject(hdc, hPenOld);
						DeleteObject(hLinePen8);
					}
					//UpdateWindow(hWnd1);
					HPEN hEllipsePen6;
					COLORREF qEllipseColor6;
					qEllipseColor6 = RGB(255, 255, 0);
					hEllipsePen6 = CreatePen(PS_SOLID, 2, qEllipseColor6);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen6);
					if (head_aux)
						if(head_aux->info==parc_t->info)
							Arc(hdc, 316, 422, 356, 462, 0, 0, 0, 0);
					//UpdateWindow(hWnd1);
					if(head_aux->left)
					{
						if(head_aux->left->info==parc_aux->info)
							Arc(hdc, 144, 487, 184,527, 0, 0, 0, 0);
						if(head_aux->left->left)
						{
							if(head_aux->left->left->info==parc_aux->info)
								Arc(hdc, 58, 552, 98,592, 0, 0, 0, 0);
							if(head_aux->left->left->left)
								if(head_aux->left->left->left->info==parc_aux->info)
									Arc(hdc, 15, 617, 55,657, 0, 0, 0, 0);
							if(head_aux->left->left->right)
								if(head_aux->left->left->right->info==parc_aux->info)
									Arc(hdc, 101, 617, 141,657, 0, 0, 0, 0);
						}
						if(head_aux->left->right)
						{
							if(head_aux->left->right->info==parc_aux->info)
								Arc(hdc, 230, 552, 270,592, 0, 0, 0, 0);
							if(head_aux->left->right->left)
								if(head_aux->left->right->left->info==parc_aux->info)
									Arc(hdc, 187, 617, 227,657, 0, 0, 0, 0);
							if(head_aux->left->right->right)
								if(head_aux->left->right->right->info==parc_aux->info)
									Arc(hdc, 273, 617, 313,657, 0, 0, 0, 0);
						}

					}
					if(head_aux->right)
					{
						if(head_aux->right->info==parc_aux->info)
							Arc(hdc, 488, 487, 528,527, 0, 0, 0, 0);
						if(head_aux->right->left)
						{
							if(head_aux->right->left->info==parc_aux->info)
								Arc(hdc, 402, 552, 442,592, 0, 0, 0, 0);
							if(head_aux->right->left->left)
								if(head_aux->right->left->left->info==parc_aux->info)
									Arc(hdc, 359, 617, 399, 657, 0, 0, 0, 0);
							if(head_aux->right->left->right)
								if(head_aux->right->left->right->info==parc_aux->info)
									Arc(hdc, 445, 617, 485, 657, 0, 0, 0, 0);
						}
						if(head_aux->right->right)
						{
							if(head_aux->right->right->info==parc_aux->info)
								Arc(hdc, 574, 552, 614,592, 0, 0, 0, 0);
							if(head_aux->right->right->left)
								if(head_aux->right->right->left->info==parc_aux->info)
									Arc(hdc, 531, 617, 571,657, 0, 0, 0, 0);
							if(head_aux->right->right->right)
								if(head_aux->right->right->right->info==parc_aux->info)
									Arc(hdc, 617, 617, 657,657, 0, 0, 0, 0);
						}
					}
					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen6);


				}
				
				if(head_aux)
				{
					itoa(head_aux->info,s,10);
					TextOut(hdc,332,434,s,strlen(s));
					
					if(head_aux->left)
					{
						itoa(head_aux->left->info,s,10);
						TextOut(hdc,160,499,s,strlen(s));

						if(head_aux->left->left)
						{
							itoa(head_aux->left->left->info,s,10);
							TextOut(hdc,74,564,s,strlen(s));
							
							if(head_aux->left->left->left)
							{
								itoa(head_aux->left->left->left->info,s,10);
								TextOut(hdc,31,629,s,strlen(s));
							}
							if(head_aux->left->left->right)
							{
								itoa(head_aux->left->left->right->info,s,10);
								TextOut(hdc,117,629,s,strlen(s));
							}
						}
						if(head_aux->left->right)
						{
							itoa(head_aux->left->right->info,s,10);
							TextOut(hdc,246,564,s,strlen(s));
							if(head_aux->left->right->left)
							{
								itoa(head_aux->left->right->left->info,s,10);
								TextOut(hdc,203,629,s,strlen(s));
							}
							if(head_aux->left->right->right)
							{
								itoa(head_aux->left->right->right->info,s,10);
								TextOut(hdc,289,629,s,strlen(s));
							}
						}

					}
					if(head_aux->right)
					{
						itoa(head_aux->right->info,s,10);
						TextOut(hdc,500,499,s,strlen(s));
						if(head_aux->right->left)
						{
							itoa(head_aux->right->left->info,s,10);
							TextOut(hdc,414,564,s,strlen(s));
							if(head_aux->right->left->left)
							{
								itoa(head_aux->right->left->left->info,s,10);
								TextOut(hdc,375,629,s,strlen(s));
							}
							if(head_aux->right->left->right)
							{
								itoa(head_aux->right->left->right->info,s,10);
								TextOut(hdc,457,629,s,strlen(s));
							}
						}
						if(head_aux->right->right)
						{
							itoa(head_aux->right->right->info,s,10);
							TextOut(hdc,586,564,s,strlen(s));
							if(head_aux->right->right->left)
							{
								itoa(head_aux->right->right->left->info,s,10);
								TextOut(hdc,543,629,s,strlen(s));
							}
							if(head_aux->right->right->right)
							{
								itoa(head_aux->right->right->right->info,s,10);
								TextOut(hdc,629,629,s,strlen(s));
							}
						}
					}
				}	
					

				ReleaseDC(hWnd1, hdc);
				UpdateWindow(hWnd1);

				if(parc_t->info==cautat)
				{
					head_aux=NULL;
					parc_aux=NULL;
									
					RECT *r;
					r=(RECT*)malloc(sizeof(RECT));
					r->left=0;
					r->top=0;
					r->right=1360;
					r->bottom=748;
					
					HBRUSH hbrush;
					hbrush=CreateSolidBrush(RGB(255,255,255));
					FillRect(hdc,r,hbrush);
					//InvalidateRect(hWnd1,r,FALSE); 
				
					HPEN hLinePen15;
					COLORREF qLineColor15;
					qLineColor15 = RGB(0, 0, 0);
					hLinePen15 = CreatePen(PS_SOLID, 2, qLineColor15);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen15);

					MoveToEx(hdc, 0, 374, NULL);
					LineTo(hdc, 1370, 374);
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen15);

					tangosearch(cautat);
					freetangotree();

					
					 if(numar_noduri==31)
					{
					
						SendMessage(hWnd1,WM_PAINT,0,0);
						hdc = GetWindowDC(hWnd1);
				    	 
					
						 // Draw black lines
					HPEN hLinePen;
					COLORREF qLineColor;
					qLineColor = RGB(0, 0, 0);
					hLinePen = CreatePen(PS_SOLID, 2, qLineColor);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen);

					MoveToEx(hdc, 0, 374, NULL);
					LineTo(hdc, 1370, 374);

					//arborele de sus
					MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 336, 124);
					MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 1024, 124);

					MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 164, 189);
					MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 508, 189);
					MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 852, 189);
					MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 1196, 189);


					MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 78, 254 );
					MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 250,254 );
					MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 422,254 );
					MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 594,254 );
					MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 766,254 );
					MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 938,254 );
					MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1110,254 );
					MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1282,254 );

					MoveToEx(hdc, 78, 294, NULL);
					LineTo(hdc, 35,319 );
					MoveToEx(hdc, 78, 294, NULL);
					LineTo(hdc, 121,319 );
					MoveToEx(hdc, 250, 294, NULL);
					LineTo(hdc, 207,319 );
					MoveToEx(hdc, 250, 294, NULL);
					LineTo(hdc, 293,319 );
					MoveToEx(hdc, 422, 294, NULL);
					LineTo(hdc, 379,319 );
					MoveToEx(hdc, 422, 294, NULL);
					LineTo(hdc, 465,319 );
					MoveToEx(hdc, 594, 294, NULL);
					LineTo(hdc, 551,319 );
					MoveToEx(hdc, 594, 294, NULL);
					LineTo(hdc, 637,319 );
					MoveToEx(hdc, 766, 294, NULL);
					LineTo(hdc, 723,319 );
					MoveToEx(hdc, 766, 294, NULL);
					LineTo(hdc, 809,319 );
					MoveToEx(hdc, 938, 294, NULL);
					LineTo(hdc, 895,319 );
					MoveToEx(hdc, 938, 294, NULL);
					LineTo(hdc, 981,319 );
					MoveToEx(hdc, 1110, 294, NULL);
					LineTo(hdc, 1067,319 );
					MoveToEx(hdc, 1110, 294, NULL);
					LineTo(hdc, 1153,319 );
					MoveToEx(hdc, 1282, 294, NULL);
					LineTo(hdc, 1239,319 );
					MoveToEx(hdc, 1282, 294 , NULL);
					LineTo(hdc, 1320,319 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen);


					//nodurile arborelui
					HPEN hEllipsePen;
					COLORREF qEllipseColor;
					qEllipseColor = RGB(0, 0, 255);
					hEllipsePen = CreatePen(PS_SOLID, 2, qEllipseColor);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen);

					//arborele de sus
					//nodul de pe nivelul 1
					Arc(hdc, 660, 59, 700, 99, 0, 0, 0, 0);

					//nodurile de pe nivelul 5
					Arc(hdc, 15, 319, 55,359, 0, 0, 0, 0);
					Arc(hdc, 101, 319, 141,359, 0, 0, 0, 0);
					Arc(hdc, 187, 319, 227,359, 0, 0, 0, 0);
					Arc(hdc, 273, 319, 313,359, 0, 0, 0, 0);
					Arc(hdc, 359, 319, 399, 359, 0, 0, 0, 0);
					Arc(hdc, 445, 319, 485,359, 0, 0, 0, 0);
					Arc(hdc, 531, 319, 571,359, 0, 0, 0, 0);
					Arc(hdc, 617, 319, 657,359, 0, 0, 0, 0);
					Arc(hdc, 703, 319, 743,359, 0, 0, 0, 0);
					Arc(hdc, 789, 319, 829,359, 0, 0, 0, 0);
					Arc(hdc, 875, 319, 915,359, 0, 0, 0, 0);
					Arc(hdc, 961, 319, 1001,359, 0, 0, 0, 0);
					Arc(hdc, 1047, 319, 1087,359, 0, 0, 0, 0);
					Arc(hdc, 1133, 319, 1173,359, 0, 0, 0, 0);
					Arc(hdc, 1219, 319, 1259,359, 0, 0, 0, 0);
					Arc(hdc, 1300, 319, 1340,359, 0, 0, 0, 0);

					//nodurile de pe nivelul 4
					Arc(hdc, 58, 254, 98,294, 0, 0, 0, 0);
					Arc(hdc, 230, 254, 270,294, 0, 0, 0, 0);
					Arc(hdc, 402, 254, 442,294, 0, 0, 0, 0);
					Arc(hdc, 574, 254, 614,294, 0, 0, 0, 0);
					Arc(hdc, 746, 254, 786,294, 0, 0, 0, 0);
					Arc(hdc, 918, 254, 958,294, 0, 0, 0, 0);
					Arc(hdc, 1090, 254, 1130,294, 0, 0, 0, 0);
					Arc(hdc, 1262, 254, 1302,294, 0, 0, 0, 0);

					//nodurile de pe nivelul 3
					Arc(hdc, 144, 189, 184,229, 0, 0, 0, 0);
					Arc(hdc, 488, 189, 528,229, 0, 0, 0, 0);
					Arc(hdc, 832, 189, 872,229, 0, 0, 0, 0);
					Arc(hdc, 1176, 189, 1216,229, 0, 0, 0, 0);

					//nodurile de pe nivelul 2
					Arc(hdc, 316, 124, 356, 164, 0, 0, 0, 0);
					Arc(hdc, 1004, 124, 1044, 164, 0, 0, 0, 0);

					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen);

					TextOut(hdc,672,71,"16",2);

					TextOut(hdc,332,136,"8",1);
					TextOut(hdc,1016,136,"24",2);
					
					TextOut(hdc,160,201,"4",1);
					TextOut(hdc,500,201,"12",2);
					TextOut(hdc,844,201,"20",2);
					TextOut(hdc,1188,201,"28",2);
					
					TextOut(hdc,74,266,"2",1);
					TextOut(hdc,246,266,"6",1);
					TextOut(hdc,414,266,"10",2);
					TextOut(hdc,586,266,"14",2);
					TextOut(hdc,758,266,"18",2);
					TextOut(hdc,930,266,"22",2);
					TextOut(hdc,1102,266,"26",2);
					TextOut(hdc,1274,266,"30",2);
					
					TextOut(hdc,31,331,"1",1);
					TextOut(hdc,117,331,"3",1);
					TextOut(hdc,203,331,"5",1);
					TextOut(hdc,289,331,"7",1);
					TextOut(hdc,375,331,"9",1);
					TextOut(hdc,457,331,"11",2);
					TextOut(hdc,543,331,"13",2);
					TextOut(hdc,629,331,"15",2);
					TextOut(hdc,715,331,"17",2);
					TextOut(hdc,801,331,"19",2);
					TextOut(hdc,887,331,"21",2);
					TextOut(hdc,973,331,"23",2);
					TextOut(hdc,1059,331,"25",2);
					TextOut(hdc,1145,331,"27",2);
					TextOut(hdc,1231,331,"29",2);
					TextOut(hdc,1312,331,"31",2);
					
					//pentru preferred path
					HPEN hLinePen3;
					COLORREF qLineColor3;
					qLineColor3 = RGB(255, 0, 0);
					hLinePen3 = CreatePen(PS_SOLID, 2, qLineColor3);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen3);

					//nivel 1
					if(headref->preferatstg==true)
					{
						MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 336, 124);
					}
					if(headref->preferatdreapta==true)
					{
						MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 1024, 124);
					}
					
					//nivel 2
					if(headref->left->preferatstg==true)
					{
						MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 164, 189);
					}
					if(headref->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 508, 189);
					}
					if(headref->right->preferatstg==true)
					{
						MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 852, 189);
					}
					if(headref->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 1196, 189);
					}

					//nivel 3
					if(headref->left->left->preferatstg==true)
					{
						MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 78, 254 );
					}
					if(headref->left->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 250,254 );
					}
					if(headref->left->right->preferatstg==true)
					{
						MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 422,254 );
					}
					if(headref->left->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 594,254 );
					}
					if(headref->right->left->preferatstg==true)
					{
						MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 766,254 );
					}
					if(headref->right->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 938,254 );
					}
					if(headref->right->right->preferatstg==true)
					{
						MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1110,254 );
					}
					if(headref->right->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1282,254 );
					}

					//nivel 4
					if(headref->left->left->left->preferatstg==true)
					{
						MoveToEx(hdc, 78, 294, NULL);
					LineTo(hdc, 35,319 );
					}
					if(headref->left->left->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 78, 294, NULL);
					LineTo(hdc, 121,319 );
					}
					if(headref->left->left->right->preferatstg==true)
					{
						MoveToEx(hdc, 250, 294, NULL);
					LineTo(hdc, 207,319 );
					}
					if(headref->left->left->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 250, 294, NULL);
					LineTo(hdc, 293,319 );
					}
					if(headref->left->right->left->preferatstg==true)
					{
						MoveToEx(hdc, 422, 294, NULL);
					LineTo(hdc, 379,319 );
					}
					if(headref->left->right->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 422, 294, NULL);
					LineTo(hdc, 465,319 );
					}
					if(headref->left->right->right->preferatstg==true)
					{
						MoveToEx(hdc, 594, 294, NULL);
					LineTo(hdc, 551,319 );
					}
					if(headref->left->right->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 594, 294, NULL);
					LineTo(hdc, 637,319 );
					}
					if(headref->right->left->left->preferatstg==true)
					{
						MoveToEx(hdc, 766, 294, NULL);
					LineTo(hdc, 723,319 );
					}
					if(headref->right->left->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 766, 294, NULL);
					LineTo(hdc, 809,319 );
					}
					if(headref->right->left->right->preferatstg==true)
					{
						MoveToEx(hdc, 938, 294, NULL);
					LineTo(hdc, 895,319 );
					}
					if(headref->right->left->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 938, 294, NULL);
					LineTo(hdc, 981,319 );
					}
					if(headref->right->right->left->preferatstg==true)
					{
						MoveToEx(hdc, 1110, 294, NULL);
					LineTo(hdc, 1067,319 );
					}
					if(headref->right->right->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 1110, 294, NULL);
					LineTo(hdc, 1153,319 );
					}
					if(headref->right->right->right->preferatstg==true)
					{
						MoveToEx(hdc, 1282, 294, NULL);
					LineTo(hdc, 1239,319 );
					}
					if(headref->right->right->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 1282, 294 , NULL);
					LineTo(hdc, 1320,319 );
					}
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen3);
					
					UpdateWindow(hWnd1);

					//pentru root-urile arborilor auxiliari
					HPEN hEllipsePen3;
					COLORREF qEllipseColor3;
					qEllipseColor3 = RGB(0, 210, 0);
					hEllipsePen3 = CreatePen(PS_SOLID, 2, qEllipseColor3);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen3);
					
					//nod nivel 1
					if(headref->isroot==true)
						Arc(hdc, 660, 59, 700, 99, 0, 0, 0, 0);
					
					//noduri nivel 2
					if(headref->left->isroot==true)
						Arc(hdc, 316, 124, 356, 164, 0, 0, 0, 0);
					if(headref->right->isroot==true)
						Arc(hdc, 1004, 124, 1044, 164, 0, 0, 0, 0);

					//noduri nivel 3
					if(headref->left->left->isroot==true)
						Arc(hdc, 144, 189, 184,229, 0, 0, 0, 0);
					if(headref->left->right->isroot==true)
						Arc(hdc, 488, 189, 528,229, 0, 0, 0, 0);
					if(headref->right->left->isroot==true)
						Arc(hdc, 832, 189, 872,229, 0, 0, 0, 0);
					if(headref->right->right->isroot==true)
						Arc(hdc, 1176, 189, 1216,229, 0, 0, 0, 0);

					//noduri nivel 4
					if(headref->left->left->left->isroot==true)
						Arc(hdc, 58, 254, 98,294, 0, 0, 0, 0);
					if(headref->left->left->right->isroot==true)
						Arc(hdc, 230, 254, 270,294, 0, 0, 0, 0);
					if(headref->left->right->left->isroot==true)
						Arc(hdc, 402, 254, 442,294, 0, 0, 0, 0);
					if(headref->left->right->right->isroot==true)
						Arc(hdc, 574, 254, 614,294, 0, 0, 0, 0);
					if(headref->right->left->left->isroot==true)
						Arc(hdc, 746, 254, 786,294, 0, 0, 0, 0);
					if(headref->right->left->right->isroot==true)
						Arc(hdc, 918, 254, 958,294, 0, 0, 0, 0);
					if(headref->right->right->left->isroot==true)
						Arc(hdc, 1090, 254, 1130,294, 0, 0, 0, 0);
					if(headref->right->right->right->isroot==true)
						Arc(hdc, 1262, 254, 1302,294, 0, 0, 0, 0);

					//noduri nivel 5
					if(headref->left->left->left->left->isroot==true)
						Arc(hdc, 15, 319, 55,359, 0, 0, 0, 0);
					if(headref->left->left->left->right->isroot==true)
						Arc(hdc, 101, 319, 141,359, 0, 0, 0, 0);
					if(headref->left->left->right->left->isroot==true)
						Arc(hdc, 187, 319, 227,359, 0, 0, 0, 0);
					if(headref->left->left->right->right->isroot==true)
						Arc(hdc, 273, 319, 313,359, 0, 0, 0, 0);
					if(headref->left->right->left->left->isroot==true)
						Arc(hdc, 359, 319, 399, 359, 0, 0, 0, 0);
					if(headref->left->right->left->right->isroot==true)
						Arc(hdc, 445, 319, 485,359, 0, 0, 0, 0);
					if(headref->left->right->right->left->isroot==true)
						Arc(hdc, 531, 319, 571,359, 0, 0, 0, 0);
					if(headref->left->right->right->right->isroot==true)
						Arc(hdc, 617, 319, 657,359, 0, 0, 0, 0);
					if(headref->right->left->left->left->isroot==true)
						Arc(hdc, 703, 319, 743,359, 0, 0, 0, 0);
					if(headref->right->left->left->right->isroot==true)
						Arc(hdc, 789, 319, 829,359, 0, 0, 0, 0);
					if(headref->right->left->right->left->isroot==true)
						Arc(hdc, 875, 319, 915,359, 0, 0, 0, 0);
					if(headref->right->left->right->right->isroot==true)
						Arc(hdc, 961, 319, 1001,359, 0, 0, 0, 0);
					if(headref->right->right->left->left->isroot==true)
						Arc(hdc, 1047, 319, 1087,359, 0, 0, 0, 0);
					if(headref->right->right->left->right->isroot==true)
						Arc(hdc, 1133, 319, 1173,359, 0, 0, 0, 0);
					if(headref->right->right->right->left->isroot==true)
						Arc(hdc, 1219, 319, 1259,359, 0, 0, 0, 0);
					if(headref->right->right->right->right->isroot==true)
						Arc(hdc, 1300, 319, 1340,359, 0, 0, 0, 0);

					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen3);

					


					//Legenda pentru REFERENCE TREE
					TextOut(hdc,1174,59,"LEGENDA",7);
					//pentru nod
					HPEN hLinePen4;
					COLORREF qLineColor4;
					qLineColor4 = RGB(0, 0, 255);
					hLinePen4 = CreatePen(PS_SOLID, 6, qLineColor4);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen4);

					MoveToEx(hdc, 1124, 89 , NULL);
					LineTo(hdc, 1154,89 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen4);

					TextOut(hdc,1174,79,"nod",3);

					//pentru legatura
					HPEN hLinePen5;
					COLORREF qLineColor5;
					qLineColor5 = RGB(0, 0, 0);
					hLinePen5 = CreatePen(PS_SOLID, 6, qLineColor5);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen5);

					MoveToEx(hdc, 1124, 109 , NULL);
					LineTo(hdc, 1154,109 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen5);

					TextOut(hdc,1174,99,"legatura",8);

					//pentru Preferred Path
					HPEN hLinePen6;
					COLORREF qLineColor6;
					qLineColor6 = RGB(255, 0, 0);
					hLinePen6 = CreatePen(PS_SOLID, 6, qLineColor6);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen6);

					MoveToEx(hdc, 1124, 129 , NULL);
					LineTo(hdc, 1154,129 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen6);

					TextOut(hdc,1174,119,"Preferred Path",14);

					//pentru Root Aux Trees
					HPEN hLinePen7;
					COLORREF qLineColor7;
					qLineColor7 = RGB(0, 255, 0);
					hLinePen7 = CreatePen(PS_SOLID, 6, qLineColor7);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen7);

					MoveToEx(hdc, 1124, 149 , NULL);
					LineTo(hdc, 1154,149 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen7);

					TextOut(hdc,1174,139,"Root pentru Aux Trees",21);

					//pentru nodul curent
					HPEN hLinePen11;
					COLORREF qLineColor11;
					qLineColor11=RGB(255,255,0);
					hLinePen11=CreatePen(PS_SOLID,6,qLineColor11);
					hPenOld=(HPEN)SelectObject(hdc,hLinePen11);
					
					MoveToEx(hdc, 1124, 169 , NULL);
					LineTo(hdc, 1154,169 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen7);

					TextOut(hdc,1174,159,"Nodul Curent din Aux",20);

					

					//incercare
					if (pro==1)
					{
					RECT *ro;
					ro=(RECT*)malloc(sizeof(RECT));
					ro->left=0;
					ro->top=370;
					ro->right=1360;
					ro->bottom=748;
				

					HBRUSH hbrush1;
					hbrush1=CreateSolidBrush(RGB(255,255,255));
					FillRect(hdc,ro,hbrush1);
					InvalidateRect(hWnd1,ro,FALSE); 

					HPEN hLinePen35;
					COLORREF qLineColor35;
					qLineColor35 = RGB(0, 0, 0);
					hLinePen35 = CreatePen(PS_SOLID, 2, qLineColor35);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen35);

					MoveToEx(hdc, 0, 374, NULL);
					LineTo(hdc, 1370, 374);
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen35);
					
					}



					UpdateWindow(hWnd1);

					ReleaseDC(hWnd1, hdc);
							
				}

				if(numar_noduri==15)
				{
						
						SendMessage(hWnd1,WM_PAINT,0,0);
						hdc = GetWindowDC(hWnd1);
						 HPEN hPenOld;
					
						 // Draw black lines
					HPEN hLinePen;
					COLORREF qLineColor;
					qLineColor = RGB(0, 0, 0);
					hLinePen = CreatePen(PS_SOLID, 2, qLineColor);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen);

					MoveToEx(hdc, 0, 374, NULL);
					LineTo(hdc, 1360, 374);

					//arborele de sus
					MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 336, 124);
					MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 1024, 124);

					MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 164, 189);
					MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 508, 189);
					MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 852, 189);
					MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 1196, 189);


					MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 78, 254 );
					MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 250,254 );
					MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 422,254 );
					MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 594,254 );
					MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 766,254 );
					MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 938,254 );
					MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1110,254 );
					MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1282,254 );
					MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 336, 124);
					MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 1024, 124);

					MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 164, 189);
					MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 508, 189);
					MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 852, 189);
					MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 1196, 189);


					MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 78, 254 );
					MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 250,254 );
					MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 422,254 );
					MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 594,254 );
					MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 766,254 );
					MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 938,254 );
					MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1110,254 );
					MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1282,254 );
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen);

					//sterg liniile spre randul 5 de noduri
					HPEN hLinePen2;
					COLORREF qLineColor2;
					qLineColor2 = RGB(255, 255, 255);
					hLinePen2 = CreatePen(PS_SOLID, 2, qLineColor2);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen2);

					MoveToEx(hdc, 78, 294, NULL);
					LineTo(hdc, 35,319 );
					MoveToEx(hdc, 78, 294, NULL);
					LineTo(hdc, 121,319 );
					MoveToEx(hdc, 250, 294, NULL);
					LineTo(hdc, 207,319 );
					MoveToEx(hdc, 250, 294, NULL);
					LineTo(hdc, 293,319 );
					MoveToEx(hdc, 422, 294, NULL);
					LineTo(hdc, 379,319 );
					MoveToEx(hdc, 422, 294, NULL);
					LineTo(hdc, 465,319 );
					MoveToEx(hdc, 594, 294, NULL);
					LineTo(hdc, 551,319 );
					MoveToEx(hdc, 594, 294, NULL);
					LineTo(hdc, 637,319 );
					MoveToEx(hdc, 766, 294, NULL);
					LineTo(hdc, 723,319 );
					MoveToEx(hdc, 766, 294, NULL);
					LineTo(hdc, 809,319 );
					MoveToEx(hdc, 938, 294, NULL);
					LineTo(hdc, 895,319 );
					MoveToEx(hdc, 938, 294, NULL);
					LineTo(hdc, 981,319 );
					MoveToEx(hdc, 1110, 294, NULL);
					LineTo(hdc, 1067,319 );
					MoveToEx(hdc, 1110, 294, NULL);
					LineTo(hdc, 1153,319 );
					MoveToEx(hdc, 1282, 294, NULL);
					LineTo(hdc, 1239,319 );
					MoveToEx(hdc, 1282, 294 , NULL);
					LineTo(hdc, 1320,319 );
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen2);


					//Desenarea nodurilor
					HPEN hEllipsePen;
					COLORREF qEllipseColor;
					qEllipseColor = RGB(0, 0, 255);
					hEllipsePen = CreatePen(PS_SOLID, 2, qEllipseColor);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen);

					//nodul de pe nivelul 1
					Arc(hdc, 660, 59, 700, 99, 0, 0, 0, 0);
					

					//nodurile de pe nivelul 4
					Arc(hdc, 58, 254, 98,294, 0, 0, 0, 0);
					Arc(hdc, 230, 254, 270,294, 0, 0, 0, 0);
					Arc(hdc, 402, 254, 442,294, 0, 0, 0, 0);
					Arc(hdc, 574, 254, 614,294, 0, 0, 0, 0);
					Arc(hdc, 746, 254, 786,294, 0, 0, 0, 0);
					Arc(hdc, 918, 254, 958,294, 0, 0, 0, 0);
					Arc(hdc, 1090, 254, 1130,294, 0, 0, 0, 0);
					Arc(hdc, 1262, 254, 1302,294, 0, 0, 0, 0);

					//nodurile de pe nivelul 3
					Arc(hdc, 144, 189, 184,229, 0, 0, 0, 0);
					Arc(hdc, 488, 189, 528,229, 0, 0, 0, 0);
					Arc(hdc, 832, 189, 872,229, 0, 0, 0, 0);
					Arc(hdc, 1176, 189, 1216,229, 0, 0, 0, 0);

					//nodurile de pe nivelul 2
					Arc(hdc, 316, 124, 356, 164, 0, 0, 0, 0);
					Arc(hdc, 1004, 124, 1044, 164, 0, 0, 0, 0);

					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen);

					//sterg nodurile de pe nivelul 5

					HPEN hEllipsePen2;
					COLORREF qEllipseColor2;
					qEllipseColor2 = RGB(255, 255, 255);
					hEllipsePen2 = CreatePen(PS_SOLID, 2, qEllipseColor2);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen2);
					
					Arc(hdc, 15, 319, 55,359, 0, 0, 0, 0);
					Arc(hdc, 101, 319, 141,359, 0, 0, 0, 0);
					Arc(hdc, 187, 319, 227,359, 0, 0, 0, 0);
					Arc(hdc, 273, 319, 313,359, 0, 0, 0, 0);
					Arc(hdc, 359, 319, 399, 359, 0, 0, 0, 0);
					Arc(hdc, 445, 319, 485,359, 0, 0, 0, 0);
					Arc(hdc, 531, 319, 571,359, 0, 0, 0, 0);
					Arc(hdc, 617, 319, 657,359, 0, 0, 0, 0);
					Arc(hdc, 703, 319, 743,359, 0, 0, 0, 0);
					Arc(hdc, 789, 319, 829,359, 0, 0, 0, 0);
					Arc(hdc, 875, 319, 915,359, 0, 0, 0, 0);
					Arc(hdc, 961, 319, 1001,359, 0, 0, 0, 0);
					Arc(hdc, 1047, 319, 1087,359, 0, 0, 0, 0);
					Arc(hdc, 1133, 319, 1173,359, 0, 0, 0, 0);
					Arc(hdc, 1219, 319, 1259,359, 0, 0, 0, 0);
					Arc(hdc, 1300, 319, 1340,359, 0, 0, 0, 0);
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen2);
					
					TextOut(hdc,672,71,"",2);
					TextOut(hdc,676,71,"8",2);

					TextOut(hdc,332,136,"4",1);
					TextOut(hdc,1016,136,"12",2);
					
					TextOut(hdc,160,201,"2",1);
					TextOut(hdc,500,201,"",2);
					TextOut(hdc,504,201,"6",2);
					TextOut(hdc,844,201,"10",2);
					TextOut(hdc,1188,201,"14",2);
					
					TextOut(hdc,74,266,"1",1);
					TextOut(hdc,246,266,"3",1);
					TextOut(hdc,414,266,"",2);
					TextOut(hdc,418,266,"5",2);
					TextOut(hdc,586,266,"",2);
					TextOut(hdc,590,266,"7",2);
					TextOut(hdc,758,266,"",2);
					TextOut(hdc,762,266,"9",2);
					TextOut(hdc,930,266,"11",2);
					TextOut(hdc,1102,266,"13",2);
					TextOut(hdc,1274,266,"15",2);

					//ascund nodurile de pe ultimul rand
					TextOut(hdc,31,331,"",1);
					TextOut(hdc,117,331,"",1);
					TextOut(hdc,203,331,"",1);
					TextOut(hdc,289,331,"",1);
					TextOut(hdc,375,331,"",1);
					TextOut(hdc,457,331,"",2);
					TextOut(hdc,543,331,"",2);
					TextOut(hdc,629,331,"",2);
					TextOut(hdc,715,331,"",2);
					TextOut(hdc,801,331,"",2);
					TextOut(hdc,887,331,"",2);
					TextOut(hdc,973,331,"",2);
					TextOut(hdc,1059,331,"",2);
					TextOut(hdc,1145,331,"",2);
					TextOut(hdc,1231,331,"",2);
					TextOut(hdc,1312,331,"",2);

					//pentru preferred path
					
					HPEN hLinePen3;
					COLORREF qLineColor3;
					qLineColor3 = RGB(255, 0, 0);
					hLinePen3 = CreatePen(PS_SOLID, 2, qLineColor3);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen3);
					
					//nivel 1
					if(headref->preferatstg==true)
					{
						MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 336, 124);
					}
					if(headref->preferatdreapta==true)
					{
						MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 1024, 124);
					}
					
					//nivel 2
					if(headref->left->preferatstg==true)
					{
						MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 164, 189);
					}
					if(headref->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 508, 189);
					}
					if(headref->right->preferatstg==true)
					{
						MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 852, 189);
					}
					if(headref->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 1196, 189);
					}

					//nivel 3
					if(headref->left->left->preferatstg==true)
					{
						MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 78, 254 );
					}
					if(headref->left->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 250,254 );
					}
					if(headref->left->right->preferatstg==true)
					{
						MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 422,254 );
					}
					if(headref->left->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 594,254 );
					}
					if(headref->right->left->preferatstg==true)
					{
						MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 766,254 );
					}
					if(headref->right->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 938,254 );
					}
					if(headref->right->right->preferatstg==true)
					{
						MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1110,254 );
					}
					if(headref->right->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1282,254 );
					}
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen3);
					
					//pentru root-urile arborilor auxiliari
					HPEN hEllipsePen3;
					COLORREF qEllipseColor3;
					qEllipseColor3 = RGB(0, 210, 0);
					hEllipsePen3 = CreatePen(PS_SOLID, 2, qEllipseColor3);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen3);
					
					//nod nivel 1
					if(headref->isroot==true)
						Arc(hdc, 660, 59, 700, 99, 0, 0, 0, 0);
					
					//noduri nivel 2
					if(headref->left->isroot==true)
						Arc(hdc, 316, 124, 356, 164, 0, 0, 0, 0);
					if(headref->right->isroot==true)
						Arc(hdc, 1004, 124, 1044, 164, 0, 0, 0, 0);

					//noduri nivel 3
					if(headref->left->left->isroot==true)
						Arc(hdc, 144, 189, 184,229, 0, 0, 0, 0);
					if(headref->left->right->isroot==true)
						Arc(hdc, 488, 189, 528,229, 0, 0, 0, 0);
					if(headref->right->left->isroot==true)
						Arc(hdc, 832, 189, 872,229, 0, 0, 0, 0);
					if(headref->right->right->isroot==true)
						Arc(hdc, 1176, 189, 1216,229, 0, 0, 0, 0);

					//noduri nivel 4
					if(headref->left->left->left->isroot==true)
						Arc(hdc, 58, 254, 98,294, 0, 0, 0, 0);
					if(headref->left->left->right->isroot==true)
						Arc(hdc, 230, 254, 270,294, 0, 0, 0, 0);
					if(headref->left->right->left->isroot==true)
						Arc(hdc, 402, 254, 442,294, 0, 0, 0, 0);
					if(headref->left->right->right->isroot==true)
						Arc(hdc, 574, 254, 614,294, 0, 0, 0, 0);
					if(headref->right->left->left->isroot==true)
						Arc(hdc, 746, 254, 786,294, 0, 0, 0, 0);
					if(headref->right->left->right->isroot==true)
						Arc(hdc, 918, 254, 958,294, 0, 0, 0, 0);
					if(headref->right->right->left->isroot==true)
						Arc(hdc, 1090, 254, 1130,294, 0, 0, 0, 0);
					if(headref->right->right->right->isroot==true)
						Arc(hdc, 1262, 254, 1302,294, 0, 0, 0, 0);

					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen3);

					//Legenda pentru REFERENCE TREE
					TextOut(hdc,1174,59,"LEGENDA",7);
					//pentru nod
					HPEN hLinePen4;
					COLORREF qLineColor4;
					qLineColor4 = RGB(0, 0, 255);
					hLinePen4 = CreatePen(PS_SOLID, 6, qLineColor4);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen4);

					MoveToEx(hdc, 1124, 89 , NULL);
					LineTo(hdc, 1154,89 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen4);

					TextOut(hdc,1174,79,"nod",3);

					//pentru legatura
					HPEN hLinePen5;
					COLORREF qLineColor5;
					qLineColor5 = RGB(0, 0, 0);
					hLinePen5 = CreatePen(PS_SOLID, 6, qLineColor5);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen5);

					MoveToEx(hdc, 1124, 109 , NULL);
					LineTo(hdc, 1154,109 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen5);

					TextOut(hdc,1174,99,"legatura",8);

					//pentru Preferred Path
					HPEN hLinePen6;
					COLORREF qLineColor6;
					qLineColor6 = RGB(255, 0, 0);
					hLinePen6 = CreatePen(PS_SOLID, 6, qLineColor6);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen6);

					MoveToEx(hdc, 1124, 129 , NULL);
					LineTo(hdc, 1154,129 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen6);

					TextOut(hdc,1174,119,"Preferred Path",14);

					//pentru Root Aux Trees
					HPEN hLinePen7;
					COLORREF qLineColor7;
					qLineColor7 = RGB(0, 255, 0);
					hLinePen7 = CreatePen(PS_SOLID, 6, qLineColor7);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen7);

					MoveToEx(hdc, 1124, 149 , NULL);
					LineTo(hdc, 1154,149 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen7);

					TextOut(hdc,1174,139,"Root pentru Aux Trees",21);

					//pentru nodul curent
					HPEN hLinePen11;
					COLORREF qLineColor11;
					qLineColor11=RGB(255,255,0);
					hLinePen11=CreatePen(PS_SOLID,6,qLineColor11);
					hPenOld=(HPEN)SelectObject(hdc,hLinePen11);
					
					MoveToEx(hdc, 1124, 169 , NULL);
					LineTo(hdc, 1154,169 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen7);

					TextOut(hdc,1174,159,"Nodul Curent din Aux",20);

					//incercare
					if (pro==1)
					{
					RECT *ro;
					ro=(RECT*)malloc(sizeof(RECT));
					ro->left=0;
					ro->top=370;
					ro->right=1360;
					ro->bottom=748;
				

					HBRUSH hbrush1;
					hbrush1=CreateSolidBrush(RGB(255,255,255));
					FillRect(hdc,ro,hbrush1);
					InvalidateRect(hWnd1,ro,FALSE); 

					HPEN hLinePen35;
					COLORREF qLineColor35;
					qLineColor35 = RGB(0, 0, 0);
					hLinePen35 = CreatePen(PS_SOLID, 2, qLineColor35);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen35);

					MoveToEx(hdc, 0, 374, NULL);
					LineTo(hdc, 1370, 374);
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen35);
					
					
					}
					RECT *p;
					p=(RECT*)malloc(sizeof(RECT));
					p->left=15;
					p->top=319;
					p->right=1340;
					p->bottom=359;
				

					HBRUSH hbrush10;
					hbrush10=CreateSolidBrush(RGB(255,255,255));
					FillRect(hdc,p,hbrush10);
					
					UpdateWindow(hWnd1);


					ReleaseDC(hWnd1, hdc);
					}
					if (pro==1) 
						{
						pro=0;
						::MessageBox(hWnd1, _T("Nodul cautat a fost gasit") , _T("Cautare"), MB_OK);
						EndDialog(hwnd, IDD_OK);
						
					}
					else pro++;
				
					//trebuie sters arborele auxiliar
				}
				else
				{
					if(parc_t->info>cautat)
					{
						parc_t=parc_t->left;
						parc_aux=parc_aux->left;
					}
					else
					{
						parc_t=parc_t->right;
						parc_aux=parc_aux->right;
					}
				}
				
				break;
			default:
				break;
			}
			break;
        default:
            return FALSE;
    }
    return TRUE;
}


//
//  FUNCTION: MyRegisterClass()
//
//  PURPOSE: Registers the window class.
//
//  COMMENTS:
//
//    This function and its usage are only necessary if you want this code
//    to be compatible with Win32 systems prior to the 'RegisterClassEx'
//    function that was added to Windows 95. It is important to call this function
//    so that the application will get 'well formed' small icons associated
//    with it.*
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX);

	wcex.style			= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc	= WndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= hInstance;
	wcex.hIcon			= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TANGOFRENZY));
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
	wcex.lpszMenuName	= MAKEINTRESOURCE(IDC_TANGOFRENZY);
	wcex.lpszClassName	= szWindowClass;
	wcex.hIconSm		= LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

	return RegisterClassEx(&wcex);
}



//
//   FUNCTION: InitInstance(HINSTANCE, int)
//
//   PURPOSE: Saves instance handle and creates main window
//
//   COMMENTS:
//
//        In this function, we save the instance handle in a global variable and
//        create and display the main program window.
//



BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   HWND hWnd;

   hInst = hInstance; // Store instance handle in our global variable

   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      0, 0, 1366, 748, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

   

   ShowWindow(hWnd, nCmdShow);
   //ShowWindow(hWnd, SW_MAXIMIZE);
   UpdateWindow(hWnd);

   return TRUE;
}

//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;

	switch (message)
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDM_ABOUT:
			::MessageBox(hWnd, _T("Demonstrator grafic Tango Trees.\nCreat de Ghinea Razvan si Iordache George\nE211B\n") , _T("About"), MB_OK);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		case IDM_CRARB:
			 ret=DialogBox(GetModuleHandle(NULL), 
                MAKEINTRESOURCE(IDD_CONTROLSDLG), hWnd, AboutDlgProc);
			 if (numar_noduri!=0)
			 {
				 if(ret=IDD_OK)
				 {
					 freememnod(headref);
					 headref=NULL;
					 cautat=0;
					 if (fac_cautare)
					 {
						 fac_cautare=0;
						 
						 

						 RECT *ro;
					ro=(RECT*)malloc(sizeof(RECT));
					ro->left=0;
					ro->top=370;
					ro->right=1360;
					ro->bottom=748;
				

					HBRUSH hbrush40;
					hbrush40=CreateSolidBrush(RGB(255,255,255));
					FillRect(hdc,ro,hbrush40);
					InvalidateRect(hWnd1,ro,TRUE); 

					HPEN hLinePen35;
					COLORREF qLineColor35;
					qLineColor35 = RGB(0, 0, 0);
					hLinePen35 = CreatePen(PS_SOLID, 2, qLineColor35);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen35);

					MoveToEx(hdc, 0, 374, NULL);
					LineTo(hdc, 1370, 374);
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen35);
					UpdateWindow(hWnd);

					EndDialog(btnext,0);
					 }
					 ref_tree();
					 //construire arbore

					 if(numar_noduri==31)
					{
					
						SendMessage(hWnd,WM_PAINT,0,0);
						hdc = GetWindowDC(hWnd);
				    	 
					
						 // Draw black lines
					HPEN hLinePen;
					COLORREF qLineColor;
					qLineColor = RGB(0, 0, 0);
					hLinePen = CreatePen(PS_SOLID, 2, qLineColor);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen);

					MoveToEx(hdc, 0, 374, NULL);
					LineTo(hdc, 1370, 374);

					//arborele de sus
					MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 336, 124);
					MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 1024, 124);

					MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 164, 189);
					MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 508, 189);
					MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 852, 189);
					MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 1196, 189);


					MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 78, 254 );
					MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 250,254 );
					MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 422,254 );
					MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 594,254 );
					MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 766,254 );
					MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 938,254 );
					MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1110,254 );
					MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1282,254 );

					MoveToEx(hdc, 78, 294, NULL);
					LineTo(hdc, 35,319 );
					MoveToEx(hdc, 78, 294, NULL);
					LineTo(hdc, 121,319 );
					MoveToEx(hdc, 250, 294, NULL);
					LineTo(hdc, 207,319 );
					MoveToEx(hdc, 250, 294, NULL);
					LineTo(hdc, 293,319 );
					MoveToEx(hdc, 422, 294, NULL);
					LineTo(hdc, 379,319 );
					MoveToEx(hdc, 422, 294, NULL);
					LineTo(hdc, 465,319 );
					MoveToEx(hdc, 594, 294, NULL);
					LineTo(hdc, 551,319 );
					MoveToEx(hdc, 594, 294, NULL);
					LineTo(hdc, 637,319 );
					MoveToEx(hdc, 766, 294, NULL);
					LineTo(hdc, 723,319 );
					MoveToEx(hdc, 766, 294, NULL);
					LineTo(hdc, 809,319 );
					MoveToEx(hdc, 938, 294, NULL);
					LineTo(hdc, 895,319 );
					MoveToEx(hdc, 938, 294, NULL);
					LineTo(hdc, 981,319 );
					MoveToEx(hdc, 1110, 294, NULL);
					LineTo(hdc, 1067,319 );
					MoveToEx(hdc, 1110, 294, NULL);
					LineTo(hdc, 1153,319 );
					MoveToEx(hdc, 1282, 294, NULL);
					LineTo(hdc, 1239,319 );
					MoveToEx(hdc, 1282, 294 , NULL);
					LineTo(hdc, 1320,319 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen);


					//nodurile arborelui
					HPEN hEllipsePen;
					COLORREF qEllipseColor;
					qEllipseColor = RGB(0, 0, 255);
					hEllipsePen = CreatePen(PS_SOLID, 2, qEllipseColor);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen);

					//arborele de sus
					//nodul de pe nivelul 1
					Arc(hdc, 660, 59, 700, 99, 0, 0, 0, 0);

					//nodurile de pe nivelul 5
					Arc(hdc, 15, 319, 55,359, 0, 0, 0, 0);
					Arc(hdc, 101, 319, 141,359, 0, 0, 0, 0);
					Arc(hdc, 187, 319, 227,359, 0, 0, 0, 0);
					Arc(hdc, 273, 319, 313,359, 0, 0, 0, 0);
					Arc(hdc, 359, 319, 399, 359, 0, 0, 0, 0);
					Arc(hdc, 445, 319, 485,359, 0, 0, 0, 0);
					Arc(hdc, 531, 319, 571,359, 0, 0, 0, 0);
					Arc(hdc, 617, 319, 657,359, 0, 0, 0, 0);
					Arc(hdc, 703, 319, 743,359, 0, 0, 0, 0);
					Arc(hdc, 789, 319, 829,359, 0, 0, 0, 0);
					Arc(hdc, 875, 319, 915,359, 0, 0, 0, 0);
					Arc(hdc, 961, 319, 1001,359, 0, 0, 0, 0);
					Arc(hdc, 1047, 319, 1087,359, 0, 0, 0, 0);
					Arc(hdc, 1133, 319, 1173,359, 0, 0, 0, 0);
					Arc(hdc, 1219, 319, 1259,359, 0, 0, 0, 0);
					Arc(hdc, 1300, 319, 1340,359, 0, 0, 0, 0);

					//nodurile de pe nivelul 4
					Arc(hdc, 58, 254, 98,294, 0, 0, 0, 0);
					Arc(hdc, 230, 254, 270,294, 0, 0, 0, 0);
					Arc(hdc, 402, 254, 442,294, 0, 0, 0, 0);
					Arc(hdc, 574, 254, 614,294, 0, 0, 0, 0);
					Arc(hdc, 746, 254, 786,294, 0, 0, 0, 0);
					Arc(hdc, 918, 254, 958,294, 0, 0, 0, 0);
					Arc(hdc, 1090, 254, 1130,294, 0, 0, 0, 0);
					Arc(hdc, 1262, 254, 1302,294, 0, 0, 0, 0);

					//nodurile de pe nivelul 3
					Arc(hdc, 144, 189, 184,229, 0, 0, 0, 0);
					Arc(hdc, 488, 189, 528,229, 0, 0, 0, 0);
					Arc(hdc, 832, 189, 872,229, 0, 0, 0, 0);
					Arc(hdc, 1176, 189, 1216,229, 0, 0, 0, 0);

					//nodurile de pe nivelul 2
					Arc(hdc, 316, 124, 356, 164, 0, 0, 0, 0);
					Arc(hdc, 1004, 124, 1044, 164, 0, 0, 0, 0);

					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen);

					TextOut(hdc,672,71,"16",2);

					TextOut(hdc,332,136,"8",1);
					TextOut(hdc,1016,136,"24",2);
					
					TextOut(hdc,160,201,"4",1);
					TextOut(hdc,500,201,"12",2);
					TextOut(hdc,844,201,"20",2);
					TextOut(hdc,1188,201,"28",2);
					
					TextOut(hdc,74,266,"2",1);
					TextOut(hdc,246,266,"6",1);
					TextOut(hdc,414,266,"10",2);
					TextOut(hdc,586,266,"14",2);
					TextOut(hdc,758,266,"18",2);
					TextOut(hdc,930,266,"22",2);
					TextOut(hdc,1102,266,"26",2);
					TextOut(hdc,1274,266,"30",2);
					
					TextOut(hdc,31,331,"1",1);
					TextOut(hdc,117,331,"3",1);
					TextOut(hdc,203,331,"5",1);
					TextOut(hdc,289,331,"7",1);
					TextOut(hdc,375,331,"9",1);
					TextOut(hdc,457,331,"11",2);
					TextOut(hdc,543,331,"13",2);
					TextOut(hdc,629,331,"15",2);
					TextOut(hdc,715,331,"17",2);
					TextOut(hdc,801,331,"19",2);
					TextOut(hdc,887,331,"21",2);
					TextOut(hdc,973,331,"23",2);
					TextOut(hdc,1059,331,"25",2);
					TextOut(hdc,1145,331,"27",2);
					TextOut(hdc,1231,331,"29",2);
					TextOut(hdc,1312,331,"31",2);
					
					//pentru preferred path
					HPEN hLinePen3;
					COLORREF qLineColor3;
					qLineColor3 = RGB(255, 0, 0);
					hLinePen3 = CreatePen(PS_SOLID, 2, qLineColor3);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen3);

					//nivel 1
					if(headref->preferatstg==true)
					{
						MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 336, 124);
					}
					if(headref->preferatdreapta==true)
					{
						MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 1024, 124);
					}
					
					//nivel 2
					if(headref->left->preferatstg==true)
					{
						MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 164, 189);
					}
					if(headref->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 508, 189);
					}
					if(headref->right->preferatstg==true)
					{
						MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 852, 189);
					}
					if(headref->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 1196, 189);
					}

					//nivel 3
					if(headref->left->left->preferatstg==true)
					{
						MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 78, 254 );
					}
					if(headref->left->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 250,254 );
					}
					if(headref->left->right->preferatstg==true)
					{
						MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 422,254 );
					}
					if(headref->left->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 594,254 );
					}
					if(headref->right->left->preferatstg==true)
					{
						MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 766,254 );
					}
					if(headref->right->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 938,254 );
					}
					if(headref->right->right->preferatstg==true)
					{
						MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1110,254 );
					}
					if(headref->right->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1282,254 );
					}

					//nivel 4
					if(headref->left->left->left->preferatstg==true)
					{
						MoveToEx(hdc, 78, 294, NULL);
					LineTo(hdc, 35,319 );
					}
					if(headref->left->left->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 78, 294, NULL);
					LineTo(hdc, 121,319 );
					}
					if(headref->left->left->right->preferatstg==true)
					{
						MoveToEx(hdc, 250, 294, NULL);
					LineTo(hdc, 207,319 );
					}
					if(headref->left->left->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 250, 294, NULL);
					LineTo(hdc, 293,319 );
					}
					if(headref->left->right->left->preferatstg==true)
					{
						MoveToEx(hdc, 422, 294, NULL);
					LineTo(hdc, 379,319 );
					}
					if(headref->left->right->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 422, 294, NULL);
					LineTo(hdc, 465,319 );
					}
					if(headref->left->right->right->preferatstg==true)
					{
						MoveToEx(hdc, 594, 294, NULL);
					LineTo(hdc, 551,319 );
					}
					if(headref->left->right->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 594, 294, NULL);
					LineTo(hdc, 637,319 );
					}
					if(headref->right->left->left->preferatstg==true)
					{
						MoveToEx(hdc, 766, 294, NULL);
					LineTo(hdc, 723,319 );
					}
					if(headref->right->left->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 766, 294, NULL);
					LineTo(hdc, 809,319 );
					}
					if(headref->right->left->right->preferatstg==true)
					{
						MoveToEx(hdc, 938, 294, NULL);
					LineTo(hdc, 895,319 );
					}
					if(headref->right->left->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 938, 294, NULL);
					LineTo(hdc, 981,319 );
					}
					if(headref->right->right->left->preferatstg==true)
					{
						MoveToEx(hdc, 1110, 294, NULL);
					LineTo(hdc, 1067,319 );
					}
					if(headref->right->right->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 1110, 294, NULL);
					LineTo(hdc, 1153,319 );
					}
					if(headref->right->right->right->preferatstg==true)
					{
						MoveToEx(hdc, 1282, 294, NULL);
					LineTo(hdc, 1239,319 );
					}
					if(headref->right->right->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 1282, 294 , NULL);
					LineTo(hdc, 1320,319 );
					}
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen3);
					
					UpdateWindow(hWnd);

					//pentru root-urile arborilor auxiliari
					HPEN hEllipsePen3;
					COLORREF qEllipseColor3;
					qEllipseColor3 = RGB(0, 210, 0);
					hEllipsePen3 = CreatePen(PS_SOLID, 2, qEllipseColor3);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen3);
					
					//nod nivel 1
					if(headref->isroot==true)
						Arc(hdc, 660, 59, 700, 99, 0, 0, 0, 0);
					
					//noduri nivel 2
					if(headref->left->isroot==true)
						Arc(hdc, 316, 124, 356, 164, 0, 0, 0, 0);
					if(headref->right->isroot==true)
						Arc(hdc, 1004, 124, 1044, 164, 0, 0, 0, 0);

					//noduri nivel 3
					if(headref->left->left->isroot==true)
						Arc(hdc, 144, 189, 184,229, 0, 0, 0, 0);
					if(headref->left->right->isroot==true)
						Arc(hdc, 488, 189, 528,229, 0, 0, 0, 0);
					if(headref->right->left->isroot==true)
						Arc(hdc, 832, 189, 872,229, 0, 0, 0, 0);
					if(headref->right->right->isroot==true)
						Arc(hdc, 1176, 189, 1216,229, 0, 0, 0, 0);

					//noduri nivel 4
					if(headref->left->left->left->isroot==true)
						Arc(hdc, 58, 254, 98,294, 0, 0, 0, 0);
					if(headref->left->left->right->isroot==true)
						Arc(hdc, 230, 254, 270,294, 0, 0, 0, 0);
					if(headref->left->right->left->isroot==true)
						Arc(hdc, 402, 254, 442,294, 0, 0, 0, 0);
					if(headref->left->right->right->isroot==true)
						Arc(hdc, 574, 254, 614,294, 0, 0, 0, 0);
					if(headref->right->left->left->isroot==true)
						Arc(hdc, 746, 254, 786,294, 0, 0, 0, 0);
					if(headref->right->left->right->isroot==true)
						Arc(hdc, 918, 254, 958,294, 0, 0, 0, 0);
					if(headref->right->right->left->isroot==true)
						Arc(hdc, 1090, 254, 1130,294, 0, 0, 0, 0);
					if(headref->right->right->right->isroot==true)
						Arc(hdc, 1262, 254, 1302,294, 0, 0, 0, 0);

					//noduri nivel 5
					if(headref->left->left->left->left->isroot==true)
						Arc(hdc, 15, 319, 55,359, 0, 0, 0, 0);
					if(headref->left->left->left->right->isroot==true)
						Arc(hdc, 101, 319, 141,359, 0, 0, 0, 0);
					if(headref->left->left->right->left->isroot==true)
						Arc(hdc, 187, 319, 227,359, 0, 0, 0, 0);
					if(headref->left->left->right->right->isroot==true)
						Arc(hdc, 273, 319, 313,359, 0, 0, 0, 0);
					if(headref->left->right->left->left->isroot==true)
						Arc(hdc, 359, 319, 399, 359, 0, 0, 0, 0);
					if(headref->left->right->left->right->isroot==true)
						Arc(hdc, 445, 319, 485,359, 0, 0, 0, 0);
					if(headref->left->right->right->left->isroot==true)
						Arc(hdc, 531, 319, 571,359, 0, 0, 0, 0);
					if(headref->left->right->right->right->isroot==true)
						Arc(hdc, 617, 319, 657,359, 0, 0, 0, 0);
					if(headref->right->left->left->left->isroot==true)
						Arc(hdc, 703, 319, 743,359, 0, 0, 0, 0);
					if(headref->right->left->left->right->isroot==true)
						Arc(hdc, 789, 319, 829,359, 0, 0, 0, 0);
					if(headref->right->left->right->left->isroot==true)
						Arc(hdc, 875, 319, 915,359, 0, 0, 0, 0);
					if(headref->right->left->right->right->isroot==true)
						Arc(hdc, 961, 319, 1001,359, 0, 0, 0, 0);
					if(headref->right->right->left->left->isroot==true)
						Arc(hdc, 1047, 319, 1087,359, 0, 0, 0, 0);
					if(headref->right->right->left->right->isroot==true)
						Arc(hdc, 1133, 319, 1173,359, 0, 0, 0, 0);
					if(headref->right->right->right->left->isroot==true)
						Arc(hdc, 1219, 319, 1259,359, 0, 0, 0, 0);
					if(headref->right->right->right->right->isroot==true)
						Arc(hdc, 1300, 319, 1340,359, 0, 0, 0, 0);

					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen3);

					


					//Legenda pentru REFERENCE TREE
					TextOut(hdc,1174,59,"LEGENDA",7);
					//pentru nod
					HPEN hLinePen4;
					COLORREF qLineColor4;
					qLineColor4 = RGB(0, 0, 255);
					hLinePen4 = CreatePen(PS_SOLID, 6, qLineColor4);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen4);

					MoveToEx(hdc, 1124, 89 , NULL);
					LineTo(hdc, 1154,89 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen4);

					TextOut(hdc,1174,79,"nod",3);

					//pentru legatura
					HPEN hLinePen5;
					COLORREF qLineColor5;
					qLineColor5 = RGB(0, 0, 0);
					hLinePen5 = CreatePen(PS_SOLID, 6, qLineColor5);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen5);

					MoveToEx(hdc, 1124, 109 , NULL);
					LineTo(hdc, 1154,109 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen5);

					TextOut(hdc,1174,99,"legatura",8);

					//pentru Preferred Path
					HPEN hLinePen6;
					COLORREF qLineColor6;
					qLineColor6 = RGB(255, 0, 0);
					hLinePen6 = CreatePen(PS_SOLID, 6, qLineColor6);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen6);

					MoveToEx(hdc, 1124, 129 , NULL);
					LineTo(hdc, 1154,129 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen6);

					TextOut(hdc,1174,119,"Preferred Path",14);

					//pentru Root Aux Trees
					HPEN hLinePen7;
					COLORREF qLineColor7;
					qLineColor7 = RGB(0, 255, 0);
					hLinePen7 = CreatePen(PS_SOLID, 6, qLineColor7);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen7);

					MoveToEx(hdc, 1124, 149 , NULL);
					LineTo(hdc, 1154,149 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen7);

					TextOut(hdc,1174,139,"Root pentru Aux Trees",21);

					//pentru nodul curent
					HPEN hLinePen11;
					COLORREF qLineColor11;
					qLineColor11=RGB(255,255,0);
					hLinePen11=CreatePen(PS_SOLID,6,qLineColor11);
					hPenOld=(HPEN)SelectObject(hdc,hLinePen11);
					
					MoveToEx(hdc, 1124, 169 , NULL);
					LineTo(hdc, 1154,169 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen7);

					TextOut(hdc,1174,159,"Nodul Curent din Aux",20);



					ReleaseDC(hWnd, hdc);
							break;
		}

		if(numar_noduri=15)
					{
						
						SendMessage(hWnd,WM_PAINT,0,0);
						hdc = GetWindowDC(hWnd);
						 HPEN hPenOld;
					
						 // Draw black lines
					HPEN hLinePen;
					COLORREF qLineColor;
					qLineColor = RGB(0, 0, 0);
					hLinePen = CreatePen(PS_SOLID, 2, qLineColor);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen);

					MoveToEx(hdc, 0, 374, NULL);
					LineTo(hdc, 1360, 374);

					//arborele de sus
					MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 336, 124);
					MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 1024, 124);

					MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 164, 189);
					MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 508, 189);
					MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 852, 189);
					MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 1196, 189);


					MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 78, 254 );
					MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 250,254 );
					MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 422,254 );
					MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 594,254 );
					MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 766,254 );
					MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 938,254 );
					MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1110,254 );
					MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1282,254 );
					MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 336, 124);
					MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 1024, 124);

					MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 164, 189);
					MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 508, 189);
					MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 852, 189);
					MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 1196, 189);


					MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 78, 254 );
					MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 250,254 );
					MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 422,254 );
					MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 594,254 );
					MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 766,254 );
					MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 938,254 );
					MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1110,254 );
					MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1282,254 );
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen);

					//sterg liniile spre randul 5 de noduri
					HPEN hLinePen2;
					COLORREF qLineColor2;
					qLineColor2 = RGB(255, 255, 255);
					hLinePen2 = CreatePen(PS_SOLID, 2, qLineColor2);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen2);

					MoveToEx(hdc, 78, 294, NULL);
					LineTo(hdc, 35,319 );
					MoveToEx(hdc, 78, 294, NULL);
					LineTo(hdc, 121,319 );
					MoveToEx(hdc, 250, 294, NULL);
					LineTo(hdc, 207,319 );
					MoveToEx(hdc, 250, 294, NULL);
					LineTo(hdc, 293,319 );
					MoveToEx(hdc, 422, 294, NULL);
					LineTo(hdc, 379,319 );
					MoveToEx(hdc, 422, 294, NULL);
					LineTo(hdc, 465,319 );
					MoveToEx(hdc, 594, 294, NULL);
					LineTo(hdc, 551,319 );
					MoveToEx(hdc, 594, 294, NULL);
					LineTo(hdc, 637,319 );
					MoveToEx(hdc, 766, 294, NULL);
					LineTo(hdc, 723,319 );
					MoveToEx(hdc, 766, 294, NULL);
					LineTo(hdc, 809,319 );
					MoveToEx(hdc, 938, 294, NULL);
					LineTo(hdc, 895,319 );
					MoveToEx(hdc, 938, 294, NULL);
					LineTo(hdc, 981,319 );
					MoveToEx(hdc, 1110, 294, NULL);
					LineTo(hdc, 1067,319 );
					MoveToEx(hdc, 1110, 294, NULL);
					LineTo(hdc, 1153,319 );
					MoveToEx(hdc, 1282, 294, NULL);
					LineTo(hdc, 1239,319 );
					MoveToEx(hdc, 1282, 294 , NULL);
					LineTo(hdc, 1320,319 );
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen2);


					//Desenarea nodurilor
					HPEN hEllipsePen;
					COLORREF qEllipseColor;
					qEllipseColor = RGB(0, 0, 255);
					hEllipsePen = CreatePen(PS_SOLID, 2, qEllipseColor);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen);

					//nodul de pe nivelul 1
					Arc(hdc, 660, 59, 700, 99, 0, 0, 0, 0);
					

					//nodurile de pe nivelul 4
					Arc(hdc, 58, 254, 98,294, 0, 0, 0, 0);
					Arc(hdc, 230, 254, 270,294, 0, 0, 0, 0);
					Arc(hdc, 402, 254, 442,294, 0, 0, 0, 0);
					Arc(hdc, 574, 254, 614,294, 0, 0, 0, 0);
					Arc(hdc, 746, 254, 786,294, 0, 0, 0, 0);
					Arc(hdc, 918, 254, 958,294, 0, 0, 0, 0);
					Arc(hdc, 1090, 254, 1130,294, 0, 0, 0, 0);
					Arc(hdc, 1262, 254, 1302,294, 0, 0, 0, 0);

					//nodurile de pe nivelul 3
					Arc(hdc, 144, 189, 184,229, 0, 0, 0, 0);
					Arc(hdc, 488, 189, 528,229, 0, 0, 0, 0);
					Arc(hdc, 832, 189, 872,229, 0, 0, 0, 0);
					Arc(hdc, 1176, 189, 1216,229, 0, 0, 0, 0);

					//nodurile de pe nivelul 2
					Arc(hdc, 316, 124, 356, 164, 0, 0, 0, 0);
					Arc(hdc, 1004, 124, 1044, 164, 0, 0, 0, 0);

					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen);

					//sterg nodurile de pe nivelul 5

					HPEN hEllipsePen2;
					COLORREF qEllipseColor2;
					qEllipseColor2 = RGB(255, 255, 255);
					hEllipsePen2 = CreatePen(PS_SOLID, 2, qEllipseColor2);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen2);
					
					Arc(hdc, 15, 319, 55,359, 0, 0, 0, 0);
					Arc(hdc, 101, 319, 141,359, 0, 0, 0, 0);
					Arc(hdc, 187, 319, 227,359, 0, 0, 0, 0);
					Arc(hdc, 273, 319, 313,359, 0, 0, 0, 0);
					Arc(hdc, 359, 319, 399, 359, 0, 0, 0, 0);
					Arc(hdc, 445, 319, 485,359, 0, 0, 0, 0);
					Arc(hdc, 531, 319, 571,359, 0, 0, 0, 0);
					Arc(hdc, 617, 319, 657,359, 0, 0, 0, 0);
					Arc(hdc, 703, 319, 743,359, 0, 0, 0, 0);
					Arc(hdc, 789, 319, 829,359, 0, 0, 0, 0);
					Arc(hdc, 875, 319, 915,359, 0, 0, 0, 0);
					Arc(hdc, 961, 319, 1001,359, 0, 0, 0, 0);
					Arc(hdc, 1047, 319, 1087,359, 0, 0, 0, 0);
					Arc(hdc, 1133, 319, 1173,359, 0, 0, 0, 0);
					Arc(hdc, 1219, 319, 1259,359, 0, 0, 0, 0);
					Arc(hdc, 1300, 319, 1340,359, 0, 0, 0, 0);
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen2);
					
					TextOut(hdc,672,71,"",2);
					TextOut(hdc,676,71,"8",2);

					TextOut(hdc,332,136,"4",1);
					TextOut(hdc,1016,136,"12",2);
					
					TextOut(hdc,160,201,"2",1);
					TextOut(hdc,500,201,"",2);
					TextOut(hdc,504,201,"6",2);
					TextOut(hdc,844,201,"10",2);
					TextOut(hdc,1188,201,"14",2);
					
					TextOut(hdc,74,266,"1",1);
					TextOut(hdc,246,266,"3",1);
					TextOut(hdc,414,266,"",2);
					TextOut(hdc,418,266,"5",2);
					TextOut(hdc,586,266,"",2);
					TextOut(hdc,590,266,"7",2);
					TextOut(hdc,758,266,"",2);
					TextOut(hdc,762,266,"9",2);
					TextOut(hdc,930,266,"11",2);
					TextOut(hdc,1102,266,"13",2);
					TextOut(hdc,1274,266,"15",2);

					//ascund nodurile de pe ultimul rand
					TextOut(hdc,31,331,"",1);
					TextOut(hdc,117,331,"",1);
					TextOut(hdc,203,331,"",1);
					TextOut(hdc,289,331,"",1);
					TextOut(hdc,375,331,"",1);
					TextOut(hdc,457,331,"",2);
					TextOut(hdc,543,331,"",2);
					TextOut(hdc,629,331,"",2);
					TextOut(hdc,715,331,"",2);
					TextOut(hdc,801,331,"",2);
					TextOut(hdc,887,331,"",2);
					TextOut(hdc,973,331,"",2);
					TextOut(hdc,1059,331,"",2);
					TextOut(hdc,1145,331,"",2);
					TextOut(hdc,1231,331,"",2);
					TextOut(hdc,1312,331,"",2);

					//pentru preferred path
					
					HPEN hLinePen3;
					COLORREF qLineColor3;
					qLineColor3 = RGB(255, 0, 0);
					hLinePen3 = CreatePen(PS_SOLID, 2, qLineColor3);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen3);
					
					//nivel 1
					if(headref->preferatstg==true)
					{
						MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 336, 124);
					}
					if(headref->preferatdreapta==true)
					{
						MoveToEx(hdc, 680, 99, NULL);
					LineTo(hdc, 1024, 124);
					}
					
					//nivel 2
					if(headref->left->preferatstg==true)
					{
						MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 164, 189);
					}
					if(headref->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 336, 164, NULL);
					LineTo(hdc, 508, 189);
					}
					if(headref->right->preferatstg==true)
					{
						MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 852, 189);
					}
					if(headref->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 1024, 164, NULL);
					LineTo(hdc, 1196, 189);
					}

					//nivel 3
					if(headref->left->left->preferatstg==true)
					{
						MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 78, 254 );
					}
					if(headref->left->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 164, 229, NULL);
					LineTo(hdc, 250,254 );
					}
					if(headref->left->right->preferatstg==true)
					{
						MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 422,254 );
					}
					if(headref->left->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 508, 229, NULL);
					LineTo(hdc, 594,254 );
					}
					if(headref->right->left->preferatstg==true)
					{
						MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 766,254 );
					}
					if(headref->right->left->preferatdreapta==true)
					{
						MoveToEx(hdc, 852, 229, NULL);
					LineTo(hdc, 938,254 );
					}
					if(headref->right->right->preferatstg==true)
					{
						MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1110,254 );
					}
					if(headref->right->right->preferatdreapta==true)
					{
						MoveToEx(hdc, 1196, 229, NULL);
					LineTo(hdc, 1282,254 );
					}
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen3);
					
					//pentru root-urile arborilor auxiliari
					HPEN hEllipsePen3;
					COLORREF qEllipseColor3;
					qEllipseColor3 = RGB(0, 210, 0);
					hEllipsePen3 = CreatePen(PS_SOLID, 2, qEllipseColor3);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen3);
					
					//nod nivel 1
					if(headref->isroot==true)
						Arc(hdc, 660, 59, 700, 99, 0, 0, 0, 0);
					
					//noduri nivel 2
					if(headref->left->isroot==true)
						Arc(hdc, 316, 124, 356, 164, 0, 0, 0, 0);
					if(headref->right->isroot==true)
						Arc(hdc, 1004, 124, 1044, 164, 0, 0, 0, 0);

					//noduri nivel 3
					if(headref->left->left->isroot==true)
						Arc(hdc, 144, 189, 184,229, 0, 0, 0, 0);
					if(headref->left->right->isroot==true)
						Arc(hdc, 488, 189, 528,229, 0, 0, 0, 0);
					if(headref->right->left->isroot==true)
						Arc(hdc, 832, 189, 872,229, 0, 0, 0, 0);
					if(headref->right->right->isroot==true)
						Arc(hdc, 1176, 189, 1216,229, 0, 0, 0, 0);

					//noduri nivel 4
					if(headref->left->left->left->isroot==true)
						Arc(hdc, 58, 254, 98,294, 0, 0, 0, 0);
					if(headref->left->left->right->isroot==true)
						Arc(hdc, 230, 254, 270,294, 0, 0, 0, 0);
					if(headref->left->right->left->isroot==true)
						Arc(hdc, 402, 254, 442,294, 0, 0, 0, 0);
					if(headref->left->right->right->isroot==true)
						Arc(hdc, 574, 254, 614,294, 0, 0, 0, 0);
					if(headref->right->left->left->isroot==true)
						Arc(hdc, 746, 254, 786,294, 0, 0, 0, 0);
					if(headref->right->left->right->isroot==true)
						Arc(hdc, 918, 254, 958,294, 0, 0, 0, 0);
					if(headref->right->right->left->isroot==true)
						Arc(hdc, 1090, 254, 1130,294, 0, 0, 0, 0);
					if(headref->right->right->right->isroot==true)
						Arc(hdc, 1262, 254, 1302,294, 0, 0, 0, 0);

					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen3);

					//Legenda pentru REFERENCE TREE
					TextOut(hdc,1174,59,"LEGENDA",7);
					//pentru nod
					HPEN hLinePen4;
					COLORREF qLineColor4;
					qLineColor4 = RGB(0, 0, 255);
					hLinePen4 = CreatePen(PS_SOLID, 6, qLineColor4);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen4);

					MoveToEx(hdc, 1124, 89 , NULL);
					LineTo(hdc, 1154,89 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen4);

					TextOut(hdc,1174,79,"nod",3);

					//pentru legatura
					HPEN hLinePen5;
					COLORREF qLineColor5;
					qLineColor5 = RGB(0, 0, 0);
					hLinePen5 = CreatePen(PS_SOLID, 6, qLineColor5);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen5);

					MoveToEx(hdc, 1124, 109 , NULL);
					LineTo(hdc, 1154,109 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen5);

					TextOut(hdc,1174,99,"legatura",8);

					//pentru Preferred Path
					HPEN hLinePen6;
					COLORREF qLineColor6;
					qLineColor6 = RGB(255, 0, 0);
					hLinePen6 = CreatePen(PS_SOLID, 6, qLineColor6);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen6);

					MoveToEx(hdc, 1124, 129 , NULL);
					LineTo(hdc, 1154,129 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen6);

					TextOut(hdc,1174,119,"Preferred Path",14);

					//pentru Root Aux Trees
					HPEN hLinePen7;
					COLORREF qLineColor7;
					qLineColor7 = RGB(0, 255, 0);
					hLinePen7 = CreatePen(PS_SOLID, 6, qLineColor7);
					hPenOld = (HPEN)SelectObject(hdc, hLinePen7);

					MoveToEx(hdc, 1124, 149 , NULL);
					LineTo(hdc, 1154,149 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen7);

					TextOut(hdc,1174,139,"Root pentru Aux Trees",21);

					
					HPEN hLinePen11;
					COLORREF qLineColor11;
					qLineColor11=RGB(255,255,0);
					hLinePen11=CreatePen(PS_SOLID,6,qLineColor11);
					hPenOld=(HPEN)SelectObject(hdc,hLinePen11);
					
					MoveToEx(hdc, 1124, 169 , NULL);
					LineTo(hdc, 1154,169 );

					SelectObject(hdc, hPenOld);
					DeleteObject(hLinePen7);

					TextOut(hdc,1174,159,"Nodul Curent din Aux",20);

					RECT *p;
					p=(RECT*)malloc(sizeof(RECT));
					p->left=15;
					p->top=319;
					p->right=1340;
					p->bottom=359;
				

					HBRUSH hbrush10;
					hbrush10=CreateSolidBrush(RGB(255,255,255));
					FillRect(hdc,p,hbrush10);
					
					
					UpdateWindow(hWnd);

					ReleaseDC(hWnd, hdc);
							break;
					}



					
				 }
			 }
				break;	
		case IDD_ABOUT:
        {
            ret = DialogBox(GetModuleHandle(NULL), 
                MAKEINTRESOURCE(IDD_ABOUT), hWnd, AboutDlgProc);
            if(ret == IDOK){
                MessageBox(hWnd, "Dialog exited with IDOK.", "Notice",
                    MB_OK | MB_ICONINFORMATION);
            }
            else if(ret == IDCANCEL){
                MessageBox(hWnd, "Dialog exited with IDCANCEL.", "Notice",
                    MB_OK | MB_ICONINFORMATION);
            }
            else if(ret == -1){
                MessageBox(hWnd, "Dialog failed!", "Error",
                    MB_OK | MB_ICONINFORMATION);
            }
        }
        break;
		case IDM_SEARCH:
			ret=-1;
			if(numar_noduri==31)
				ret=DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG1), hWnd, AboutDlgProc1);

			if(numar_noduri==15)
				ret=DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG2), hWnd, AboutDlgProc2);
		if (fac_cautare&&numar_noduri!=0)
		{
			parc_t=headtango;
			parc_lista=first;
			while(parc_t->info!=parc_lista->radacina->info)
				parc_lista=parc_lista->next;
			parc_aux=parc_lista->radacina;
			head_aux=parc_aux;
			hWnd1=hWnd;
			btnext=CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_FORMVIEW), hWnd, AboutDlgProc4);
			if(btnext!=NULL)
			{				
				SendMessage(hWnd,WM_PAINT,0,0);
				hdc = GetWindowDC(hWnd);				
				
				if(head_aux)
				{
					HPEN hEllipsePen4;
					COLORREF qEllipseColor4;
					qEllipseColor4 = RGB(0, 210, 0);
					hEllipsePen4 = CreatePen(PS_SOLID, 2, qEllipseColor4);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen4);
					
					Arc(hdc, 316, 422, 356, 462, 0, 0, 0, 0);
					
					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen4);

					HPEN hEllipsePen5;
					COLORREF qEllipseColor5;
					qEllipseColor5 = RGB(0, 0, 0);
					hEllipsePen5 = CreatePen(PS_SOLID, 2, qEllipseColor5);
					hPenOld = (HPEN)SelectObject(hdc, hEllipsePen5);
					
					if(head_aux->left)
					{
						Arc(hdc, 144, 487, 184,527, 0, 0, 0, 0);
						if(head_aux->left->left)
						{
							Arc(hdc, 58, 552, 98,592, 0, 0, 0, 0);
							if(head_aux->left->left->left)
								Arc(hdc, 15, 617, 55,657, 0, 0, 0, 0);
							if(head_aux->left->left->right)
								Arc(hdc, 101, 617, 141,657, 0, 0, 0, 0);
						}
						if(head_aux->left->right)
						{
							Arc(hdc, 230, 552, 270,592, 0, 0, 0, 0);
							if(head_aux->left->right->left)
								Arc(hdc, 187, 617, 227,657, 0, 0, 0, 0);
							if(head_aux->left->right->right)
								Arc(hdc, 273, 617, 313,657, 0, 0, 0, 0);
						}

					}
					if(head_aux->right)
					{
						Arc(hdc, 488, 487, 528,527, 0, 0, 0, 0);
						if(head_aux->right->left)
						{
							Arc(hdc, 402, 552, 442,592, 0, 0, 0, 0);
							if(head_aux->right->left->left)
								Arc(hdc, 359, 617, 399, 657, 0, 0, 0, 0);
							if(head_aux->right->left->right)
								Arc(hdc, 445, 617, 485, 657, 0, 0, 0, 0);
						}
						if(head_aux->right->right)
						{
							Arc(hdc, 574, 552, 614,592, 0, 0, 0, 0);
							if(head_aux->right->right->left)
								Arc(hdc, 531, 617, 571,657, 0, 0, 0, 0);
							if(head_aux->right->right->right)
								Arc(hdc, 617, 617, 657,657, 0, 0, 0, 0);
						}
					}
					SelectObject(hdc, hPenOld);
					DeleteObject(hEllipsePen4);
					
					
					if(head_aux)
					{
						HPEN hLinePen8;
						COLORREF qLineColor8;
						qLineColor8 = RGB(0, 0, 0);
						hLinePen8 = CreatePen(PS_SOLID, 2, qLineColor8);
						hPenOld = (HPEN)SelectObject(hdc, hLinePen8);
						if(head_aux->left)
						{
							MoveToEx(hdc, 336, 462, NULL);
							LineTo(hdc, 164, 487);
							if(head_aux->left->left)
							{
								MoveToEx(hdc, 164, 527, NULL);
								LineTo(hdc, 78, 552 );
								if(head_aux->left->left->left)
								{
									MoveToEx(hdc, 78, 592, NULL);
									LineTo(hdc, 35,617 );
								}
								if(head_aux->left->left->right)
								{
									MoveToEx(hdc, 78, 592, NULL);
									LineTo(hdc, 121,617 );
								}
							}
							if(head_aux->left->right)
							{
								MoveToEx(hdc, 164, 527, NULL);
								LineTo(hdc, 250,552 );
								if(head_aux->left->right->left)
								{
									MoveToEx(hdc, 250, 592, NULL);
									LineTo(hdc, 207,617 );
								}
								if(head_aux->left->right->right)
								{
									MoveToEx(hdc, 250, 592, NULL);
									LineTo(hdc, 293,617 );
								}
							}
						}
						if(head_aux->right)
						{
							MoveToEx(hdc, 336, 462, NULL);
							LineTo(hdc, 508, 487);
							if(head_aux->right->left)
							{
								MoveToEx(hdc, 508, 527, NULL);
								LineTo(hdc, 422,552 );
								if(head_aux->right->left->left)
								{
									MoveToEx(hdc, 422, 592, NULL);
									LineTo(hdc, 379,617 );
								}
								if(head_aux->right->left->right)
								{
									MoveToEx(hdc, 422, 592, NULL);
									LineTo(hdc, 465,617 );
								}
							}
							if(head_aux->right->right)
							{
								MoveToEx(hdc, 508, 527, NULL);
								LineTo(hdc, 594,552 );
								if(head_aux->right->right->left)
								{
									MoveToEx(hdc, 594, 592, NULL);
									LineTo(hdc, 551,617 );
								}
								if(head_aux->right->right->right)
								{
									MoveToEx(hdc, 594, 592, NULL);
									LineTo(hdc, 637,617 );
								}
							}
						}
						SelectObject(hdc, hPenOld);
						DeleteObject(hLinePen8);
					}
					
				}
				if(head_aux)
				{
					itoa(head_aux->info,s,10);
					TextOut(hdc,332,434,s,strlen(s));
					
					if(head_aux->left)
					{
						itoa(head_aux->left->info,s,10);
						TextOut(hdc,160,499,s,strlen(s));

						if(head_aux->left->left)
						{
							itoa(head_aux->left->left->info,s,10);
							TextOut(hdc,74,564,s,strlen(s));
							
							if(head_aux->left->left->left)
							{
								itoa(head_aux->left->left->left->info,s,10);
								TextOut(hdc,31,629,s,strlen(s));
							}
							if(head_aux->left->left->right)
							{
								itoa(head_aux->left->left->right->info,s,10);
								TextOut(hdc,117,629,s,strlen(s));
							}
						}
						if(head_aux->left->right)
						{
							itoa(head_aux->left->right->info,s,10);
							TextOut(hdc,246,564,s,strlen(s));
							if(head_aux->left->right->left)
							{
								itoa(head_aux->left->right->left->info,s,10);
								TextOut(hdc,203,629,s,strlen(s));
							}
							if(head_aux->left->right->right)
							{
								itoa(head_aux->left->right->right->info,s,10);
								TextOut(hdc,289,629,s,strlen(s));
							}
						}

					}
					if(head_aux->right)
					{
						itoa(head_aux->right->info,s,10);
						TextOut(hdc,500,499,s,strlen(s));
						if(head_aux->right->left)
						{
							itoa(head_aux->right->left->info,s,10);
							TextOut(hdc,414,564,s,strlen(s));
							if(head_aux->right->left->left)
							{
								itoa(head_aux->right->left->left->info,s,10);
								TextOut(hdc,375,629,s,strlen(s));
							}
							if(head_aux->right->left->right)
							{
								itoa(head_aux->right->left->right->info,s,10);
								TextOut(hdc,457,629,s,strlen(s));
							}
						}
						if(head_aux->right->right)
						{
							itoa(head_aux->right->right->info,s,10);
							TextOut(hdc,586,564,s,strlen(s));
							if(head_aux->right->right->left)
							{
								itoa(head_aux->right->right->left->info,s,10);
								TextOut(hdc,543,629,s,strlen(s));
							}
							if(head_aux->right->right->right)
							{
								itoa(head_aux->right->right->right->info,s,10);
								TextOut(hdc,629,629,s,strlen(s));
							}
						}
					}
				}
				
				ReleaseDC(hWnd, hdc);
				UpdateWindow(hWnd);
			    ShowWindow(btnext,SW_SHOW);
			
			}
		}
		break;
		}
		break;
		
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}

// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	UNREFERENCED_PARAMETER(lParam);
	switch (message)
	{
	case WM_INITDIALOG:
		return (INT_PTR)TRUE;

	case WM_COMMAND:
		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
		{
			EndDialog(hDlg, LOWORD(wParam));
			return (INT_PTR)TRUE;
		}
		break;
	}
	return (INT_PTR)FALSE;
}
